package com.com.effectivejava.generics.examples;
import com.com.effectivejava.generics.util.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;

/**
 * Created by pankaj on 7/19/14.
 */
public class ExtendsH {
    static Logger logger = Logger.getLogger(ExtendsH.class.getName());

    static {
        logger.setParent(Logger.getLogger(ExtendsH.class.getPackage().getName()));
    }

    static void print(Collection<? super Child> container){
       for(Object t: container){
            logger.info(""+t);
       }
    }

    static void add(Collection<? super Parent> container){
        container.add(new Child());
        container.add(new GrandChild());
        container.add(null);
        //container.add(new Object());
    }


    public static void main(String[] args) {

        List<Object> objects = new ArrayList<Object>(){{
            add(new Object());
            add(new Object());
        }};

        List<Parent> parents = new ArrayList<Parent>(){{
            add(new Parent());
            add(new Parent());
        }};

        List<Child> children = new ArrayList<Child>(){{
            add(new Child());
            add(new Child());
        }};

        List<GrandChild> grandChildren = new ArrayList<GrandChild>(){{
            add(new GrandChild());
            add(new GrandChild());
        }};

        //add(objects);
        add(parents);
        //add(children);
        //add(grandChildren);

        print(parents);
    }
}
